#import "dfhgwhruebvhrheycopyrightfiction.h"
@interface dfhgwhruebvhrheycopyrightfiction ()
@property (nonatomic, copy) NSString *dateString;
@property (weak, nonatomic) IBOutlet UIDatePicker *picker;
@end
@implementation dfhgwhruebvhrheycopyrightfiction {
	void(^_callback)(NSString *);
}
- (void)awakeFromNib {
	[super awakeFromNib];
	NSDate *date = [NSDate date];
	NSCalendar *calendar = [NSCalendar currentCalendar];
	NSDate *defaultDate = [calendar dateByAddingUnit:NSCalendarUnitYear value:-22 toDate:date options:0];
	NSDate *minDate = [calendar dateByAddingUnit:NSCalendarUnitYear value:-80 toDate:date options:0];
	NSDate *maxDate = [calendar dateByAddingUnit:NSCalendarUnitYear value:-18 toDate:date options:0];
	self.picker.date = defaultDate;
	self.picker.minimumDate = minDate;
	self.picker.maximumDate = maxDate;
	[self.picker addTarget:self action:@selector(dateSelect) forControlEvents:UIControlEventValueChanged];
}
- (void)showDatePopView:(void (^)(NSString *dateString))callback {
	_callback = callback;
}
- (void)dateSelect {
	NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
	formatter.dateFormat = @"MM/dd/YYYY";
	self.dateString = [formatter stringFromDate:self.picker.date];
}
- (IBAction)popBtnsAction:(UIButton *)sender {
	switch (sender.tag) {
		case 100: {
			if (_callback) {
				_callback(nil);
			}
		}
			break;
		case 200: {
			if (sender.tag == 200) {
				if (self.dateString == nil) {
					return [dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Please select birthday"];
				}
			}
			if (_callback) {
				_callback(self.dateString);
			}
		}
			break;
		default:
			break;
	}
}
@end
